<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>无标题文档</title>
    <link href="../../css/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../js/jquery.js"></script>

    <script>

        var danjia = $("#danjia");
        var shuliang = $("#shuliang");
        var zonjia = $("#zonjia");
        var flag = 0;

        function myBlur1() {
            danjia = $("#shuliang").val();
            if (danjia != 0 && shuliang != 0) {
                zonjia = danjia * shuliang;
                $(".zonjia").val(zonjia);
                if (flag > 4) {
                    return 0;
                }
                flag++;
                myBlur2();
            }
        }

        function myBlur2() {
            shuliang = $("#danjia").val();
            if (danjia != 0 && shuliang != 0) {
                zonjia = danjia * shuliang;
                $(".zonjia").val(zonjia);
                flag++;
                if (flag > 4) {
                    return 0;
                }
                myBlur1();
            }
        }

        function myBlur3() {
            shuliang = $("#shuliang").val();
            danjia = $("#danjia").val();
            if (danjia != 0 && shuliang != 0) {
                zonjia = danjia * shuliang;
                console.log("danjia: " + danjia)
                console.log("shuliang: " + shuliang)
                $(".zonjia").val(zonjia);
            }
        }

    </script>

</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li>采购管理</li>
        <li>采购单管理</li>
        <li>修改</li>
    </ul>
</div>
<form action="/purchaseOrderManage/updatePurchaseOrder" method="post">
    <input name="detailsId" type="hidden" th:value="${conn.detailsId}">
    <div class="formbody">
        <div class="formtitle"><span>采购单信息</span></div>
        <ul class="forminfo">
            <li>
                <label>采购单编号</label>
                <input name="purchaseId" type="text" th:value="${conn.purchaseId}" readonly="readonly" class="roinput"/>
                <i>自动生成不能编辑</i>
            </li>
            <li>
                <label>采购时间</label>
                <input type="text"
                       th:value="${#dates.format(conn.purchaseTime, 'yyyy-MM-dd HH:mm:ss')}" readonly="readonly"
                       class="roinput"/>
                <i>不能编辑</i>
            </li>
            <li>
                <label>创建人</label>
                <input name="createMan" type="text" value="马云" readonly="readonly" class="roinput"/>
                <i>不能编辑</i>
            </li>
            <li>
                <label>审核状态</label>
                <span th:if="${conn.checkStatus} eq 1">
                <input type="text" value="未审核" readonly="readonly" class="roinput"/>
                <input name="checkStatus" type="hidden" value="1"/><i>初始状态，不能编辑</i>
            </span>
                <span th:if="${conn.checkStatus} eq 2">
                <input type="text" value="审核中" readonly="readonly" class="roinput"/>
                <input name="checkStatus" type="hidden" value="2"/><i>初始状态，不能编辑</i>
            </span>
                <span th:if="${conn.checkStatus} eq 3">
                <input type="text" value="审核通过" readonly="readonly" class="roinput"/>
                <input name="checkStatus" type="hidden" value="3"/><i>初始状态，不能编辑</i>
            </span>
                <span th:if="${conn.checkStatus} eq 4">
                <input type="text" value="审核未通过" readonly="readonly" class="roinput"/>
                <input name="checkStatus" type="hidden" value="4"/><i>初始状态，不能编辑</i>
            </span>
            </li>
            <li>
                <label>总金额</label>
                <input name="" type="text" th:value="${conn.totalMoney}" readonly="readonly" class="roinput zonjia"
                       onblur="myBlur3()"/>
                <i>自动运算，不能编辑</i>
            </li>
            <li>
                <input type="button" value="新增" class="smallbtn"/>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" value="删除" class="smallbtn"/>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="submit" value="保存" class="smallbtn"/>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <input type="button" value="返回" class="smallbtn" onclick="window.history.go(-1);"/>
            </li>
        </ul>
        <table class="tablelist">
            <thead>
            <tr>
                <th>序号</th>
                <th>品牌</th>
                <th>类型</th>
                <th>型号</th>
                <th>厂商</th>
                <th>数量</th>
                <th>单位</th>
                <th>单价</th>
                <th>金额</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>1</td>
                <td>
                    <select th:name="tid">
                        <option th:each="type:${conn1}" th:selected="${type.BrandName}=='荣耀'" th:value="${type.brandId}"
                                th:text="${type.BrandName}" th:name="${type.brandId}"></option>
                    </select>
                </td>
                <td>
                    <select th:name="typeName">
                        <option th:each="type:${conn2}" th:selected="${type.typeName}=='手机'" th:value="${type.typeId}"
                                th:text="${type.typeName}" th:name="${type.typeId}"></option>
                    </select>
                </td>
                <td>
                    <select th:name="Models">
                        <option th:each="type:${conn3}" th:selected="${type.productModel}=='p30'" th:value="${type.productId}"
                                th:text="${type.productModel}" th:name="${type.productId}"></option>
                    </select>
                </td>
                <td>
                    <select th:name="company">
                        <option th:each="type:${conn4}" th:selected="${type.firmName}=='京东'" th:value="${type.firmId}"
                                th:text="${type.firmName}" th:name="${type.firmId}"></option>
                    </select>
                </td>
                <td><input name="count" type="text" onblur="myBlur2()" id="danjia"
                           oninput="if(!/^[0-9]+$/.test(value)) value=value.replace(/\D/g,'');
                       if(value>5000)value=5000;if(value<1)value=1" th:value="${conn.purchasePrice}">
                </td>
                <td>个</td>
                <td><input name="purchasePrice" type="text" onblur="myBlur1()" id="shuliang" th:value="${conn.count}">
                </td>
                <td><input name="totalMoney" type="text" onblur="myBlur3()" class="zonjia"
                           oninput="if(!/^[0-9]+$/.test(value)) value=value.replace(/\D/g,'');"
                           th:value="${conn.totalMoney}"></td>
            </tr>
            </tbody>
        </table>
    </div>
</form>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
